#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 1020;
int n, m, k, D;
int g[N][N];
int dist[N];
bool st[N];

int get(string s) {
    if (s[0] == 'G') return n + stoi(s.substr(1));
    return stoi(s);
}

void dijsktra(int start, int &mind, int &sumd) {
    mm(dist, INF);
    mm(st, false);

    dist[start] = 0;
    for (int i = 0; i < n + m; i ++ ) {
        int t = -1;
        for (int j = 1; j <= n + m; j ++ ) 
            if (!st[j] && (t == -1 || dist[j] < dist[t]))
                t = j;
        st[j] = true;
        for (int j = 1; j <= n + m; j ++ ) 
            dist[j] = min(dist[j], dist[t] + g[t][j]);
    }

    for (int i = 1; i <= n; i ++ ) {
        if (dist[i] > D) {
            mind = -INF;
            return ;
        }
    }
    mind = INF, sumd = 0;
    for (int i = 1; i <= n; i ++ ) {
        mind = min(mind, dist[i]);
        sumd += dist[i];
    }
}

inline void solution() {
    cin >> n >> m >> k >> D;
    mm(g, INF);
    while (k -- ) {
        string a, b;
        int z;
        cin >> a >> b >> z;
        int x = get(a), y = get(b);
        g[x][y] = g[y][x] = min(g[x][y], z);
    }

    int res = -1, mind = -INF, sumd = INF;
    for (int i = n + 1; i <= n + m; i ++ ) {
        int d1, d2;
        dijkstra(i, d1, d2);
        if (d1 > mind) res = i, mind = d1, sumd = d2;
        else if (d1 == mind && d2 < sumd) res = i, sumd = d2;
    }

    if (res == -1) puts("No Solution");
    else printf("G%d\n%.1lf %.1lf\n", res - n, mind, (double)sumd / n);
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}